//自定义一种数据类型
//习惯接口名字I开头
interface IProduct {
    id:number,
    name:string,
    price:number,
    status:boolean,
    // type:{
    //     id:number,
    //     name:string
    // }
    type:IType | null, //联合类型
    msg?:string
}
interface IType {
    id:number,
    name:string,
    showMessage:()=>void
}

//如何定义出一个数组，里面存放对象？
let products:Array<IProduct> = [
    {id:1,name:"小米",price:1200,status:true,type:{id:1,name:"家用电器",showMessage:function(){}}},
    {id:1,name:"小米",price:1200,status:true,type:null,msg:"123"},
]
const product:IProduct = products[0]

// for (const item of products) {
//     console.log(item.type.name);
    
// }



